<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>upload</title>
<%@ include file="/common/commonLib.jsp"%>
<script src="<c:url value='/js/ajaxfileupload.js'/>"></script>
</head>
<body>
<center>添加用户</center><br>
<center>
<input type="file" name="file" id="file"/>
<button onclick="ajaxFileUpload()">上传文件</button>

</center>
</body>
<script>
/* function doUpload() {  
   var formData = new FormData($( "#uploadForm" )[0]);  
    $.ajax({  
         url: "<c:url value='/resource/upload' />",
         type: 'POST',  
         data: formData,  
         async: false,  
         cache: false,  
         contentType: false,  
         processData: false,  
         success: function (data) {  
             alert(data.status); 
         },  
         error: function (returndata) {  
             alert(returndata);  
         }  
    });  
} */

	function ajaxFileUpload() {
		$.ajaxFileUpload({
			url : "<c:url value='/resource/editUpload'/>", //用于文件上传的服务器端请求地址
			secureuri : false, //是否需要安全协议，一般设置为false
			fileElementId : 'file', //文件上传域的ID
			dataType : 'json', //返回值类型 一般设置为json
			success : function(data, status) //服务器成功响应处理函数
			{
				alert("success");
			},
			error : function(data, status, e)//服务器响应失败处理函数
			{
				alert(e);
			}
		})
		return false;
	}
</script>
</html>